package com.lepu.app.main.fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.app.utils.UmengEvent;
import com.app.utils.Utils;
import com.core.lib.application.BaseFragment;
import com.core.lib.utils.main.UmengHelper;
import com.lepu.pasm.R;

public class MainTabFragmentChat extends BaseFragment {

    private static final String REQUEST_DATA = "request_data";
    private static final int MSG_DATA_SUCCESS = 10;
    private static final int MSG_DATA_FAIL = 11;

    private View mMainView = null;
    private boolean mInitDataSuccess = false;// 是否加载完数据


    @SuppressLint("InflateParams")
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mMainView = LayoutInflater.from(getActivity()).inflate(
                R.layout.main_tab_fragment_chat, null, false);
        init();
    }

    @Override
    public void onResume() {
        super.onResume();

        UmengHelper.OnPageStart(UmengEvent.page_liaoliao);
    }

    @Override
    public void onPause() {
        super.onPause();

        UmengHelper.OnPageEnd(UmengEvent.page_liaoliao);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);

        ViewGroup p = (ViewGroup) mMainView.getParent();
        if (p != null) {
            p.removeAllViewsInLayout();
        }
        return mMainView;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();

        mInitDataSuccess = false;
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);

        if (isVisibleToUser) {
            if (!mInitDataSuccess) {
                // 第一次进入页面获取数据
                request();
            }
        }
    }

	/*
     * 初始化ui控件，不要初始化数据！！！！
     *
     * 初始化控件，需要用mMainView.findViewById 不能使用findViewById，否则程序会闪退的
     */
    private void init() {
        //5.0以下关闭硬件加速
        Utils.setLayerTypeOff(mMainView);
    }
    
    private void request() {
		// TODO Auto-generated method stub
		
	}

	


}
